package com.TTBook.impl.system.serviceImpl;

import java.util.List;

import com.TTBook.core.system.dao.SysParamsDAO;
import com.TTBook.core.system.model.SysParams;
import com.TTBook.core.system.model.SysParamsCriteria;
import com.TTBook.core.system.service.SysParamsService;
import com.TTBook.utils.BookBaseServiceException;
import com.TTBook.utils.pages.DatabasePaginatedList;
import com.TTBook.utils.pages.PageUtils;

public class SysParamsServiceImpl implements SysParamsService {

	private SysParamsDAO sysParamsDAO;

	public SysParamsDAO getSysParamsDAO() {
		return sysParamsDAO;
	}

	public void setSysParamsDAO(SysParamsDAO sysParamsDAO) {
		this.sysParamsDAO = sysParamsDAO;
	}

	@Override
	public List<SysParams> getSysParamsPage(SysParams sysParams,
			int currentSkip, int pageSize) throws BookBaseServiceException {
		int count = this.sysParamsDAO.countByParams(sysParams);
		List<SysParams> list = this.sysParamsDAO.selectByParams(sysParams);
		DatabasePaginatedList<SysParams> dp = new DatabasePaginatedList<SysParams>(
				PageUtils.initPageIndex(currentSkip, pageSize), pageSize,
				count, list);
		return dp;
	}

	@Override
	public SysParams getSysParams(String innerName) throws BookBaseServiceException {
		SysParams sysParams = this.sysParamsDAO.selectByPrimaryKey(innerName);
		return sysParams;
	}

}
